package com.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
  private static Properties properties = null;
  //静态加加载块
  static{
    InputStream is = null;
    is = ConfigManager.class.getClassLoader().getResourceAsStream("database.properties");
    if(is==null){
      throw new RuntimeException("文件读取异常！");
    }
    properties = new Properties();
    try {
      properties.load(is);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  /**
   * 通过键获取值
   * @param key 传入的键
   * @return 返回的值 Object
   */
  public static Object getProperties(String key){return properties.get(key);}
}
